package com.sskj.hangqing.presenter;

import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.hangqing.bean.HangqingBannerBean;
import com.sskj.lib.bean.CoinBean;
import com.sskj.lib.bean.PageBean;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.hangqing.bean.BannerBean;
import com.sskj.hangqing.bean.GuideListBean;
import com.sskj.hangqing.http.HttpConfig;
import com.sskj.hangqing.ui.fragment.HangqingFragment;

import java.util.List;


public class HangqingFragmentPresenter extends BasePresenter<HangqingFragment> {

    public void getData() {
        httpService.getProduct(null)
                .execute(new JsonCallBack<HttpData<List<CoinBean>>>() {
                    @Override
                    public void onSuccess(Response<HttpData<List<CoinBean>>> response) {
                        HttpData<List<CoinBean>> httpData = response.body();
                        if (httpData.getStatus() == HttpConfig.OK) {

                            mView.updateUI(httpData.getData());
                        } else {
                            mView.finishRefresh();

                        }
                    }

                    @Override
                    public void onError(Response<HttpData<List<CoinBean>>> response) {
                        super.onError(response);
                        mView.finishRefresh();
                    }
                });
    }

    public void getBanner() {
        httpService.getBanner()
                .execute(new JsonCallBack<HttpData<HangqingBannerBean>>() {
                    @Override
                    public void onSuccess(Response<HttpData<HangqingBannerBean>> response) {
                        HttpData<HangqingBannerBean> httpData = response.body();
                        if (httpData.getStatus() == HttpConfig.OK) {

                            mView.updateBanner(httpData.getData());
                        }
                    }
                });
    }



}
